﻿
Imports System.Data
Imports VSModel
Imports Cls_Common

Partial Class Control_Customer_Detail
    Inherits System.Web.UI.UserControl
#Region "Sub and Function "
    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        If Not IsPostBack Then
            If Not Page.RouteData.Values("Id") Is Nothing Then
                hidID.Value = Page.RouteData.Values("Id")
                ShowData()
            End If
        End If
    End Sub
    Protected Sub ShowData()
        Using data As New VSEntities
            Dim _HotelId As Integer = Session("HotelId")

            Dim p As Customer = (From q In data.Customers Where q.CustomerId = hidID.Value And q.HotelId = _HotelId Select q).SingleOrDefault
            If Not p Is Nothing Then
                lblFullname.Text = IIf(IsNothing(p.FullName) = True, "", p.FullName)
                If Not p.Sex Is Nothing AndAlso p.Sex = 1 Then
                    lblSex.Text = "Nam"
                Else
                    lblSex.Text = "Nữ"
                End If
                If Not p.DateOfBirth Is Nothing Then
                    lblDateofbirth.Text = CType(p.DateOfBirth, Date).ToString("dd/MM/yyyy")
                End If

                lblDateofbirthtype.Text = IIf(IsNothing(p.DateOfBirthType) = True, "", p.DateOfBirthType)

                lblCountryname.Text = IIf(IsNothing(p.CountryName) = True, "", p.CountryName)
                lblObject.Text = IIf(IsNothing(p.Object) = True, "", p.Object)
                lblCareer.Text = IIf(IsNothing(p.Career) = True, "", p.Career)
                lblPasspostnumber.Text = IIf(IsNothing(p.PasspostNumber) = True, "", p.PasspostNumber)
                If Not p.EntryDate Is Nothing Then
                    lblEntrydate.Text = CType(p.EntryDate, Date).ToString("dd/MM/yyyy")
                End If




                lblGatename.Text = IIf(IsNothing(p.GateName) = True, "", p.GateName)

                lblEntrypurposename.Text = IIf(IsNothing(p.EntryPurposeName) = True, "", p.EntryPurposeName)
                If lblEntrypurposename.Text = "--- Chọn ---" Then
                    lblEntrypurposename.Text = ""
                End If
                lblExpireddate.Text = IIf(IsNothing(p.ThoiHanThiThuc) = True, "", p.ThoiHanThiThuc)
                lblTemporaryresidencecard.Text = IIf(IsNothing(p.TemporaryResidenceCard) = True, "", p.TemporaryResidenceCard)


                If Not p.FromDate Is Nothing Then
                    lblFromdate.Text = CType(p.FromDate, Date).ToString("dd/MM/yyyy")
                End If


                If Not p.ToDate Is Nothing AndAlso p.ToDate <> #1/1/1900# Then
                    lblTodate.Text = CType(p.ToDate, Date).ToString("dd/MM/yyyy")
                End If

                lblAgencywelcome.Text = IIf(IsNothing(p.AgencyWelcome) = True, "", p.AgencyWelcome)


                If Not p.PrintedDate Is Nothing Then
                    lblPrinteddate.Text = CType(p.PrintedDate, Date).ToString("dd/MM/yyyy")
                End If

                lblAddress.Text = IIf(IsNothing(p.Address) = True, "", p.Address)

                If p.Hotel.HotelTypeId = 6 Then
                    regAdress.Visible = True
                End If


            End If
        End Using
    End Sub
#End Region
End Class
